﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class SimpleRec : SimpleObs
{
    public double x;
    public double y;
    public double rx;
    public double ry;

    public SimpleRec()
    {
        
    }

    public void Add(double[] v)
    {
        base.Add(v);

        x = 0;
        y = 0;

        for (int i = 0; i < vList.Count; ++i)
        {
            x += vList[i][0];
            y += vList[i][1];
        }

        x /= vList.Count;
        y /= vList.Count;

        rx = x;
        ry = y;

        for (int i = 0; i < vList.Count; ++i)
        {
            double dx = Math.Abs(vList[i][0] - x);
            double dy = Math.Abs(vList[i][1] - y);

            if (dx > (rx - x))
                rx = dx;
            if (dy > (ry - y))
                ry = dy;
        }
    }
}